package factory;

import bean.Book;
import org.springframework.beans.factory.FactoryBean;

import java.util.UUID;

/*
* 实现了BeanFactory的类,是spring可以认识的工厂类
* spring会自动调用工厂方法创建实例
* */
public class MyFactoryBeanImpl implements FactoryBean<Book> {


    @Override
    public Book getObject() throws Exception {
        System.out.println("MyFactoryBeanImpl正在帮你创建对象");
        Book book = new Book();
        book.setName(UUID.randomUUID().toString());
        return book;
    }

    @Override
    public Class<?> getObjectType() {
        return null;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
